import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import '../assets/utitls/datas'
Vue.use(Vuex,axios)

// 状态
const state = {
    screenWidth:'', // 屏幕宽度
    resData: [], // 返回的数据
}

const getters = {

}

// 同步操作
const mutations = {
    // 设置宽度并保存
    SET_SCREEN(state, {screen}){
        state.screenWidth = screen
    },
    // 保存查询结果
    RES_DATA(state, {data}){
        if(!state.resData || state.resData.length === 0){
            state.resData = data
        }else{
            state.resData = state.resData.concat(data)
        }
    }
}

// 异步
const actions = {
    // GETT_DETAILS_DATA({commit},{data})
}

export default new Vuex.Store({
    state,
    getters,
    mutations,
    actions
})